<?php
/**
 * Controller por defecto si no se usa el routes
 * 
 */
Load::models('categorias','videos','subcategorias','banners');
class IndexController extends AppController 
{
	public function index($categoria='',$subcategoria='')
	{
            $this->banner = "true";
            $banner = Load::model('banners')->getByActivo();            
            $this->banner_ruta = $banner->ruta;
	}
        
        public function buscar($categoria_name='',$subcategoria_name='')
        {   
            if($subcategoria_name != ''){                
                $this->subcategoria = Load::model('subcategorias')->getByName($subcategoria_name);                
            }else{                
                $this->categoria = Load::model('categorias')->getByNombre($categoria_name);
            }                                    
            
            $this->videos = Load::model('videos')->getVideosByCategoriaSubcategoria($categoria_name,$subcategoria_name);                                   
            
        }
        
        public function ver($video_id)
        {
             $video = Load::model('videos')->getVideo($video_id);             
             $video->setVisitas();
             $this->video = $video;            
        }
        
        public function ranking()
        {
            $this->videos = Load::model('videos')->getMoreVisited();             
        }

        public function getSubcategorias()
        {		
            View::template(null);
            $this->categoria_id = Input::post('categoria_id');	
        }
        
       /* public function galeria($categoria_name='',$subcategoria_name='',$page=1)
        {
            
            $this->nivel = 'categorias';
            $this->videos = Load::model('videos')->getAllVideosbyVisits($page);            
            
            if($subcategoria_name != ''){  
                $this->nivel = 'final';
                $this->categorias = Load::model('subcategorias')->getByName($subcategoria_name);                
            }else if($categoria_name != ''){
                $this->nivel = 'subcategorias';
                $this->categorias = Load::model('categorias')->getByNombre($categoria_name);
            }else $this->categorias = Load::model('categorias')->find();   
            
            
        }*/
}
